#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include "DString.h"

void main(void) {
    DString myString1, myString2, myString3;
    int i, max1 = 5, max2 = 9, max3 = 0;
    //测试初始化函数
    Initiate(&myString1, max1, "Data");
    Initiate(&myString2, max2, "Structure");
    Initiate(&myString3, max3, "");
    printf("初始myString2串：    ");
    for(i = 0; i < myString2.length; i++)
        printf("%c", myString2.str[i]);
    printf("    maxLength = %d", myString2.maxLength);
    printf("    length = %d\n", myString2.length);
    //测试插入函数
    Insert(&myString2, 0, myString1);
    printf("插入子串后myString2串：    ");
    for(i = 0; i < myString2.length; i++)
        printf("%c", myString2.str[i]);
    printf("    maxLength = %d", myString2.maxLength);
    printf("    length = %d\n", myString2.length);
    //测试删除函数
    Delete(&myString2, 0, 5);
    printf("删除子串后myString2串：    ");
    for(i = 0; i < myString2.length; i++)
        printf("%c", myString2.str[i]);
    printf("    maxLength = %d", myString2.maxLength);
    printf("    length = %d\n", myString2.length);
    //测试取子串函数
    SubString(&myString2, 0, 5, &myString3);
    printf("取子串后myString3串：    ");
    for(i = 0; i < myString3.length; i++)
        printf("%c", myString3.str[i]);
    printf("    maxLength = %d", myString3.maxLength);
    printf("    length = %d\n", myString3.length);
    //测试撤销函数
    Destroy(&myString1);
    Destroy(&myString2);
    Destroy(&myString3);
}